package com.heima.minio;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;

import java.io.File;
import java.io.FileInputStream;

/**
 * @author DiXiaoNie
 * @since 2022/12/19 16:51
 */

public class UpdateTest {
    public static void main(String[] args) throws Exception {
        //1.获取文件的stream流
        FileInputStream stream = new FileInputStream(new File("D:\\develop\\list.html"));

        //2.配置minio
        MinioClient client = MinioClient.builder()
                .endpoint("http://192.168.56.130:9000")
                .credentials("minio", "minio123")
                .build();
        //3.确定上传文件
        PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                .bucket("toutiao")
                .object("aa.html")
                .contentType("text/html")
                .stream(stream,stream.available(),-1)
                .build();
        //4.上传文件
        client.putObject(putObjectArgs);
    }
}
